<?php
/*
	[English learning system]
	NAME:admin_control
*/
if (!defined('IN_ELS'))
{
    die('Hacking attempt');
}
class control extends admin_userbase {
	var $pagecount 		= 0;
	var $currendnum 	= 1;
	var $pageSize 		= 15;	//每页多少条
	var $pageNumSize 	= 10;	//分页数
	
	function control() {
		$this->admin_userbase();
		
		$act=empty($_REQUEST['a']) ? 'select' : $_REQUEST['a'];
		if($act=="login"){
			if($this->doLogin()){
//				$this->adminIframe();
				$this->pageRedirect("admin.php?p=admin_user");
			}else{
				$this->loginPage();
			}
			exit;
		}
		
		if($act=="select") 				$this->select();
		if($act=="del")						$this->deladmins();
		if($act=="add")						$this->addadmin();
		
	}
	
	function deladmins()
	{
		
		$aid = " uid=".$_REQUEST['a_id'];
			$this->db->query("delete from admins where ".$aid);
			$this->pageRedirect("admin.php?p=admin_user");
	}
	
	function select()
	{
		$admin_list = $this->getAllAdmin();
		$admin_num = $this->getNum();
		$this->view->assign('numbers',$admin_num);
		$this->view->assign('list',$admin_list);
		
		
		$this->view->display('admin_user');
	}
	function addadmin()
	{
		
		
		if($_REQUEST['ad']=='ad')
		{
			
			$name = $_REQUEST['username'];
			$pwd = MD5($_REQUEST['pwd']);
			$this->db->query("insert into admins(username,password,regdate) values('".$name."','".$pwd."','".time()."')");
			$this->pageRedirect("admin.php?p=admin_user");
		}
		
		
		
			$this->view->display('admin_user_add');
	}

	
	
}
?>